package com.lightsh.tabhost;

import com.lightsh.widget.R;
import com.lightsh.tabhost.MyTabWidget.OnTabSelectionChanged;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ImageView.ScaleType;

public class MyAnimTabWidget extends RelativeLayout{
	private Context mContext;
	private MyTabWidget mWidget;
	private ImageView mBackgroundView;
	public MyAnimTabWidget(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		init();
	}
	private void init(){		
		mBackgroundView = new ImageView(mContext);
		mBackgroundView.setScaleType(ScaleType.FIT_XY);
		LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
		super.addView(mBackgroundView, lp);
		
		mWidget = new MyTabWidget(mContext);
		lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		super.addView(mWidget, lp);		
		mWidget.setBackgroundView(mBackgroundView);
	}
	
	@Override
	public void addView(View child) {
		mWidget.addView(child);
	}
	
	public void setTabSelectionListener(OnTabSelectionChanged listener){
		mWidget.setTabSelectionListener(listener);
	}
	public View getChildTabViewAt(int tabIndex){
		return mWidget.getChildTabViewAt(tabIndex);
	}
	public void focusCurrentTab(int index){
		mWidget.focusCurrentTab(index);
	}
	public void setTabWidgetAnimBackground(int resource){
		mBackgroundView.setImageResource(resource);
	}
}
